//
// Created by Asus on 2025/6/1.
//

#include <iostream>

class Base1 {
public:
    int m_A;
protected:
    int m_B;
private:
    int m_C;
};

class Son1 : public Base1 {
public:
    void func() {
        m_A; //可访问 public权限
        m_B; //可访问 protected权限
        //m_C; //不可访问
    }
};

void myClass1() {
    Son1 son1;
    son1.func();
    son1.m_A; //其他类只能访问到公共权限
}

class Son2:protected Base1
{
public:
    void func()
    {
        m_A; //可访问 protected权限
        m_B; //可访问 protected权限
        //m_C; //不可访问
    }
};
void myClass2()
{
    Son2 s;
    //s.m_A; //不可访问
}

class Son3:private Base1
{
public:
    void func()
    {
        m_A; //可访问 private权限
        m_B; //可访问 private权限
        //m_C; //不可访问
    }
};

class GrandSon3 :public Son3
{
public:
    void func()
    {
        //Son3是私有继承，所以继承Son3的属性在GrandSon3中都无法访问到
        //m_A;
        //m_B;
        //m_C;
    }
};

int main(int argc, char *argv[]) {
    //  父类中私有成员也是被子类继承下去了，只是由编译器给隐藏后访问不到 sizeof 12 3个 int类型成员变量
    std::cout << "sizeof(Son1): " << sizeof(Son1) << std::endl;
    return 0;
}
